Hello engineers and hobbyists!
This seems like a frequent use-case: turning an address into a bit saying "it's my turn" or "ignore the data".
For that, just an equal sign works:
if (address == 0x3F)
But if we look at things from the opposite angle, it might be seen as turning an address into an array of "clock select" signal, one bit per peripheral. Like it is on SPI, with an "enable" signal (en0, en1, en2...).
┌─────┐
│ t0 │
┌───────en0 │
│ ┌───data │
┌───────────┐ │ │ └─────┘
│ decoder │ │ │ ┌─────┐
│ en0───┘ │ │ t1 │
─sel en1───────────en1 │
─data en2───┐ ├───data │
│ │ │ │ └─────┘
│ data───│───┤ ┌─────┐
└───────────┘ │ │ │ t2 │
└───────en2 │
└───data │
└─────┘
This would permit me to write modules with all the "bus" architecture out of the way.
For instance (I do not know VHDL yet, so it is Verilog): using
https://stackoverflow.com/questions/1378159/ I could then make a batch of PWM channels in an array of CHANNELS instances:
wb_pwm_channel #(
.BITS(BITS)
) channel[CHANNELS-1:0] (
.wb_clk_i(wb_clk_i),
.wb_rst_i(wb_rst_i),
.wb_dat_i(wb_dat_i[BITS-1:0]),
.wb_stb_i(channel_sel),
.pwm_counter(counter),
.pwm_channel(pwm)
);
Here, wb_* are some of the BUS signals (wishbone), pwm_* are used for the bus logic, and channel_sel would be an array of CHANNELS bits, and as per the Verilog syntax, each bits would get dispatched to one instance making it its "enable" signal.
I am much a beginner, yet I did not come across the name of the well-known method for doing this.
Any hint?
More lengthy description of the problem:
https://www.josuah.net/blog/1650637875/