Skip to content

Commit e2496aa

Browse files
committed
Add parameter to make prescale read-only
1 parent 499dbbd commit e2496aa

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

rtl/i2c_master_wbs_8.v

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ THE SOFTWARE.
3232
module i2c_master_wbs_8 #
3333
(
3434
parameter DEFAULT_PRESCALE = 1,
35+
parameter FIXED_PRESCALE = 0,
3536
parameter CMD_FIFO = 1,
3637
parameter CMD_FIFO_ADDR_WIDTH = 5,
3738
parameter WRITE_FIFO = 1,
@@ -384,11 +385,15 @@ always @* begin
384385
end
385386
4'h6: begin
386387
// prescale low
387-
prescale_next[7:0] = wbs_dat_i;
388+
if (!FIXED_PRESCALE) begin
389+
prescale_next[7:0] = wbs_dat_i;
390+
end
388391
end
389392
4'h7: begin
390393
// prescale high
391-
prescale_next[15:8] = wbs_dat_i;
394+
if (!FIXED_PRESCALE) begin
395+
prescale_next[15:8] = wbs_dat_i;
396+
end
392397
end
393398
endcase
394399
wbs_ack_o_next = ~wbs_ack_o_reg;

tb/test_i2c_master_wbs_8.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def bench():
4747

4848
# Parameters
4949
DEFAULT_PRESCALE = 1
50+
FIXED_PRESCALE = 0
5051
CMD_FIFO = 1
5152
CMD_FIFO_ADDR_WIDTH = 5
5253
WRITE_FIFO = 1

tb/test_i2c_master_wbs_8.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module test_i2c_master_wbs_8;
3333

3434
// Parameters
3535
parameter DEFAULT_PRESCALE = 1;
36+
parameter FIXED_PRESCALE = 0;
3637
parameter CMD_FIFO = 1;
3738
parameter CMD_FIFO_ADDR_WIDTH = 5;
3839
parameter WRITE_FIFO = 1;
@@ -91,6 +92,7 @@ end
9192

9293
i2c_master_wbs_8 #(
9394
.DEFAULT_PRESCALE(DEFAULT_PRESCALE),
95+
.FIXED_PRESCALE(FIXED_PRESCALE),
9496
.CMD_FIFO(CMD_FIFO),
9597
.CMD_FIFO_ADDR_WIDTH(CMD_FIFO_ADDR_WIDTH),
9698
.WRITE_FIFO(WRITE_FIFO),

0 commit comments

Comments
 (0)