Skip to content

Commit 0fc9a9c

Browse files
committedJun 24, 2017
Refactoring: XC2C model now stores bitstream in block RAM for readbacks and only uses DFFs for device configuration
1 parent 1d910aa commit 0fc9a9c

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed
 

Diff for: ‎hdl/xc2c-model/XC2CBitstream.v

+30-5
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,53 @@ module XC2CBitstream(
9090
//TODO
9191

9292
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
93-
// JTAG access
93+
// JTAG access - we have a separate, untouched copy of the raw bitstream (including transfer bits etc) for readouts
94+
95+
//KNOWN ISSUE: partial bitstream writes after an erase are not correctly emulated by this code.
96+
//The entire bitstream must be written in one go to get correct readback.
97+
//Note that actual device behavior is correct, only readback is busticated.
98+
reg read_as_blank = 0;
99+
100+
reg[SHREG_WIDTH-1:0] config_read_data_raw = 0;
101+
reg[SHREG_WIDTH-1:0] ram_bitstream_for_readback[MEM_DEPTH-1:0];
102+
103+
initial begin
104+
for(row=0; row<MEM_DEPTH; row=row+1)
105+
ram_bitstream_for_readback[row] <= {SHREG_WIDTH{1'b1}}; //copied from blank EEPROM = all 1s
106+
end
94107

95108
//Read/write the EEPROM
96109
//TODO: add read enable?
97110
always @(posedge jtag_tck) begin
98111

99112
if(config_read_en)
100-
config_read_data <= ram_bitstream[config_read_addr];
113+
config_read_data_raw <= ram_bitstream_for_readback[config_read_addr];
101114

102-
if(config_write_en)
103-
ram_bitstream[config_write_addr] <= config_write_data;
115+
if(config_write_en) begin
116+
ram_bitstream[config_write_addr] <= config_write_data;
117+
ram_bitstream_for_readback[config_write_addr] <= config_write_data;
118+
read_as_blank <= 0;
119+
end
104120

105121
//Wipe the config memory
106122
//TODO: go multicycle?
107123
//If we go multicycle, how do we handle this with no clock? Real chip is self-timed internally
108124
if(config_erase) begin
125+
read_as_blank <= 1;
109126
for(row=0; row<MEM_DEPTH; row=row+1)
110-
ram_bitstream[row] <= {SHREG_WIDTH{1'b1}};
127+
ram_bitstream[row] <= {SHREG_WIDTH{1'b1}};
111128
end
112129

113130
end
114131

132+
//Muxing for readout
133+
always @(*) begin
134+
if(read_as_blank)
135+
config_read_data <= {SHREG_WIDTH{1'b1}};
136+
else
137+
config_read_data <= config_read_data_raw;
138+
end
139+
115140
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
116141
// Shuffle the bitstream out to various IP blocks
117142

0 commit comments

Comments
 (0)