<FL4SHK>
lkcl: this isn't specificially for SIMD stuff.
kaucasus has joined #nmigen
<kaucasus>
Hi folks, I'm doing my thesis on nmigen. I've got a small question. Currently trying to make a demo to show to the promotors. This means that my code should run on a FPGA dev board. We've made a board file, and uploading a blinky works. Now we want to do the following: depending on the
<kaucasus>
* Sorry, found out shift+enter didn't work
<kaucasus>
* depending on the state of a switch, either select the regular, default clock, or make the clock a pushbutton, so that we can "step" through our demo so that it doesn't run at full speed
<kaucasus>
Is that possible to do? We're currently very new, and it isn't directly clear how to do it.
<FL4SHK>
kaucasus: can't you use an enable?
kaucasus has quit [Quit: Client closed]
<FL4SHK>
oh
kaucasus has joined #nmigen
<FL4SHK>
kaucasus: can't you use an enable of some sort?
<FL4SHK>
I'm not sure if you need to handle switch bounce or not.
<kaucasus>
Probably! But how would you go on to do that? Because as far as I understand, nmigen uses the clock resource defined in your boardfile for the sync domain
<FL4SHK>
Do you need to specifically generate a clock?
<kaucasus>
not really, we just wanna step through the code, or choose free running otherwise
<FL4SHK>
Stepping through the code could, potentially, be done with `if (button down this cycle && button up last cycle)`
<FL4SHK>
I don't know if you need ot handle switch bounce or not
<FL4SHK>
you may havve to handle that as well.
<kaucasus>
Yeah, that'll probably be necessary
<FL4SHK>
I think ti depends on your dev board.
<kaucasus>
But do we need to structure our code differently then? Because it's not entirely clear to me how you'd change your regular sync code/domain to using the button
<FL4SHK>
instead of `@(posedge button)` it becomes `@(posedge clk) if (button active)`
<FL4SHK>
I don't know how you even do `@(posedge button)` in nMigen.
<FL4SHK>
It's easy in, say, SV.
<miek>
you can put all of your code in a Module and wrap it with EnableInserter
<kaucasus>
So we need to alter the verilog behind the fact? Because currently it's very nice we can just use the integrated tools to directly synthesise and make a bitfile without futzing around
<FL4SHK>
I don't think you have to alter the Verilog.
<FL4SHK>
synth tools generally want to know which of your signals as clock signals.
<FL4SHK>
Simulation is probably the only place you can do `@(posedge button)`
<vup>
you can just create a new `ClockDomain("name")`, add it to `m.domains` and then drive it from the button: `m.d.comb += ClockSignal("name").eq(the_button_signal)`, after that you can use `m.d.name += ...` to use your new domain
<kaucasus>
ahhh yeah, that could work!
<FL4SHK>
vup: so how does that handle clock constraints in the synth tool?
<vup>
FL4SHK: you can use `platform.add_clock_constraint(domain.clk, frequency)` to add a clock constraint
<FL4SHK>
I see.
<FL4SHK>
vup: what about how it's not a consistent clock?
<vup>
unless you plan on sending the clock to a PLL it should not really matter
<vup>
(you of course want to specify the maximum frequency you think you will get)
<FL4SHK>
Ah, I see. This is news to me
<vup>
most tools also support specifying jitter, but I don't think nmigen has abstractions for that currently
<whitequark>
you don't want to ever use `@(posedge button)`
<whitequark>
you want to debounce first, otherwise you'll get unpredictable results
<saki>
What's the suggestion manner for setting up PLLs/clock management?
<whitequark>
you can use `Instance` to invoke FPGA primitives directly
<saki>
Okay, that's where I was going, but wasn't sure if there was something baked in I missed. Thanks!
bvernoux1 has joined #nmigen
bvernoux has quit [Ping timeout: 260 seconds]
bvernoux1 has quit [Quit: Leaving]
bvernoux has joined #nmigen
peeps[zen] has joined #nmigen
peepsalot has quit [Ping timeout: 252 seconds]
bvernoux1 has joined #nmigen
bvernoux has quit [Ping timeout: 252 seconds]
bvernoux has joined #nmigen
bvernoux1 has quit [Ping timeout: 252 seconds]
<kaucasus>
Hey hey, I'm still a bit stuck with my problem from earlier. Currently I've got this as the minimal code: https://pastebin.com/zdxRXE6Q
<kaucasus>
Obviously it doesn't quite work, but I'm having trouble "changing" the sync domain depending on the value a switch has
<vup>
unless you specify `local=True` when you create a `ClockDomain` they are global
<vup>
so to achieve what you are going for the easiest option is probably to create two clock domains (+ the default sync once)
<vup>
one clock domain that is fed by the button
<vup>
and one clock domain that depending on the state of the switch is either fed by the button clock domain or the default sync domain
<vup>
finally you can swap out which clock domain corresponds to `sync` for the `Blinky` module by using `DomainRenamer` (like `DomainRenamer("button_or_default_sync")(Blinky())`)
<kaucasus>
and should I then change the submodule (in this case the Blinky class) that every call to m.d.sync be replaced to m.d.button_or_sync?
<vup>
thats would be the alternative to using `DomainRenamer`, but using `sync` + `DomainRenamer` is more commonly used
<kaucasus>
ahhhh DomainRenamer! That sounds like the class I would be looking for! Thanks, still new to nmigen and finding out about all the internals
bvernoux1 has joined #nmigen
bvernoux has quit [Ping timeout: 252 seconds]
dcallagh has quit [Ping timeout: 268 seconds]
dcallagh has joined #nmigen
whitequark has quit [Ping timeout: 268 seconds]
whitequark has joined #nmigen
pho has quit [Ping timeout: 246 seconds]
RobTaylor[m] has quit [Ping timeout: 246 seconds]
RobTaylor[m] has joined #nmigen
pho has joined #nmigen
jevinskie[m] has quit [Ping timeout: 268 seconds]
jamwaffles[m] has quit [Ping timeout: 250 seconds]
jevinskie[m] has joined #nmigen
jamwaffles[m] has joined #nmigen
Chips4Makers[m] has quit [Ping timeout: 264 seconds]
programmerjake has quit [Ping timeout: 250 seconds]
Chips4Makers[m] has joined #nmigen
programmerjake has joined #nmigen
Niklas[m] has quit [Ping timeout: 268 seconds]
Niklas[m] has joined #nmigen
kaucasus has quit [Quit: Client closed]
RobTaylor[m] has quit [Ping timeout: 268 seconds]
RobTaylor[m] has joined #nmigen
programmerjake has quit [Ping timeout: 268 seconds]
programmerjake has joined #nmigen
bvernoux1 is now known as bvernoux
urja has quit [Read error: Connection reset by peer]