Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Allow printfs to go to different file descriptors #1287

Open
3 tasks done
mwachs5 opened this issue Dec 20, 2019 · 7 comments
Open
3 tasks done

Feature Request: Allow printfs to go to different file descriptors #1287

mwachs5 opened this issue Dec 20, 2019 · 7 comments

Comments

@mwachs5
Copy link
Contributor

mwachs5 commented Dec 20, 2019

Checklist

  • Did you write out a description of the feature you want to see?
  • Did you look around for any related features?
  • Did you specify relevant external information?

Feature Description

When emitting printf, don't hard-code the destination file descriptor to 80000002.

Instead use something like:

`ifndef PRINTF_FD
 `define PRINTF_FD 'h80000002.
`endif

Type of Feature

  • backend code generation

Related Features

Yes this bit of code:

    def printf(str: StringLit, args: Seq[Expression]): Seq[Any] = {
      val strx = str.verilogEscape +: args.flatMap(Seq(",", _))
      Seq("$fwrite(32'h80000002,", strx, ");")
    }

External Information

@jackkoenig
Copy link
Contributor

Seems reasonable, do you have any thoughts on finer granularity like allowing different printfs to go to different files? We don't need to conflate the issues, but if it's simple enough to kill two birds with one stone, might as well.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Dec 20, 2019

hmm, not so much. It's really the user of the verilog who is going to have thoughts on where these end up.

@seldridge
Copy link
Member

@mwachs5: Do you want to change this after Verilog generation or is it something that should be Chisel-configurable?

I'm wondering if we need to add an extra define (which always seems kludgy) or if it should be an annotation that defines where things below it are sent. E.g., you annotate a module with stdout and some wire in that with stderr the prints get sent appropriately.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Dec 20, 2019

I think it's unlikely that the Chisel author is going to know where things are supposed to be sent. This is for people actually simulating the verilog in their particular environment.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Dec 20, 2019

I suppose a different level of printf (LOG, DEBUG, ERROR)> different FD could also be useful, but that's getting fancy. And also would need to be standardized by the people using the code. And could be done with grep after-the-fact.

@chick
Copy link
Contributor

chick commented Jan 12, 2020

Noting related chisel issue: Can chisel implement printf to a file #1290

@chick
Copy link
Contributor

chick commented Jan 16, 2020

If this gets implemented it would be a good idea to update the following
stackoverflow: Can chisel implement printf to a file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants