Skip to content

Commit 1f7d800

Browse files
committedJun 21, 2017
Continued initial macrocell implementation. Fixed bugs in AND array inversion. Now can do arbitrary Boolean combinatorial logic from ZIA to macrocell XOR gate, but no feedback to ZIA or stateful stuff implemented.
1 parent f1282b2 commit 1f7d800

File tree

5 files changed

+46
-11
lines changed

5 files changed

+46
-11
lines changed
 

‎hdl/xc2c-model/XC2CAndArray.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ module XC2CAndArray(zia_in, config_bits, pterm_out);
5555
//AND in the ZIA stuff
5656
for(nrow=0; nrow<40; nrow=nrow+1) begin
5757
if(!and_config[nterm][nrow*2])
58-
pterm_out[nterm] = pterm_out[nterm] & zia_in[nrow];
58+
pterm_out[nterm] = pterm_out[nterm] & ~zia_in[nrow];
5959
if(!and_config[nterm][nrow*2 + 1])
60-
pterm_out[nterm] = pterm_out[nterm] & !zia_in[nrow];
60+
pterm_out[nterm] = pterm_out[nterm] & zia_in[nrow];
6161
end
6262
end
6363
end

‎hdl/xc2c-model/XC2CBitstream.v

+4-4
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ module XC2CBitstream(
178178
//One bit per product term, two OR terms per row
179179
if( (row >= 20) && (row <= 27) ) begin
180180
for(nterm=0; nterm<56; nterm=nterm+1) begin
181-
right_or_config[(orow*2)*56 + nterm] <= ram_bitstream[orow][249 - nterm*2 + 0];
182-
right_or_config[(orow*2+1)*56 + nterm] <= ram_bitstream[orow][249 - nterm*2 + 1];
181+
right_or_config[(orow*2)*56 + nterm] <= ram_bitstream[orow][249 - nterm*2 - 0];
182+
right_or_config[(orow*2+1)*56 + nterm] <= ram_bitstream[orow][249 - nterm*2 - 1];
183183

184-
left_or_config[(orow*2)*56 + nterm] <= ram_bitstream[orow][249 - nterm*2 + 0];
185-
left_or_config[(orow*2+1)*56 + nterm] <= ram_bitstream[orow][249 - nterm*2 + 1];
184+
left_or_config[(orow*2)*56 + nterm] <= ram_bitstream[orow][10 + nterm*2 + 0];
185+
left_or_config[(orow*2+1)*56 + nterm] <= ram_bitstream[orow][10 + nterm*2 + 1];
186186
end
187187
end
188188

‎hdl/xc2c-model/XC2CDevice.v

+17-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
*/
2323
module XC2CDevice(
2424
jtag_tdi, jtag_tms, jtag_tck, jtag_tdo,
25-
dedicated_input, iob_out, iob_in, iob_t);
25+
dedicated_input, iob_out, iob_in, iob_t,
26+
done, dbgout
27+
);
2628

2729
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2830
// Device configuration
@@ -114,6 +116,9 @@ module XC2CDevice(
114116
output wire[MACROCELLS-1:0] iob_t;
115117
input wire[MACROCELLS-1:0] iob_in;
116118

119+
output wire done;
120+
output wire dbgout;
121+
117122
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
118123
// The bitstream
119124

@@ -188,7 +193,9 @@ module XC2CDevice(
188193

189194
.config_write_en(config_write_en),
190195
.config_write_addr(config_write_addr),
191-
.config_write_data(config_write_data)
196+
.config_write_data(config_write_data),
197+
198+
.config_done(done)
192199
);
193200

194201
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -308,6 +315,14 @@ module XC2CDevice(
308315
assign iob_out[5] = right_mc_out[5];
309316
assign iob_out[4] = right_mc_out[4];
310317
assign iob_out[3] = right_mc_out[3];
318+
319+
//assign iob_out[5] = right_pterms[22]; //pterm, should be copy of x
320+
//assign iob_out[4] = right_mc_out[3]; //led_0, constant 1: OR arrays 0 xor 1
321+
//assign iob_out[3] = right_mc_out[4]; //led_1, passthrough of pterm C
322+
//for MC4 this is pterm 22
311323
assign iob_out[2:0] = 3'h0;
312324

325+
//Helper to keep stuff from getting optimized out
326+
assign dbgout = ^right_mc_out ^ ^left_mc_out;
327+
313328
endmodule

‎hdl/xc2c-model/XC2CJTAG.v

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ module XC2CJTAG(
2424
tdi, tms, tck, tdo,
2525
config_erase,
2626
config_read_en, config_read_addr, config_read_data,
27-
config_write_en, config_write_addr, config_write_data);
27+
config_write_en, config_write_addr, config_write_data,
28+
config_done);
2829

2930
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3031
// Device configuration
@@ -57,6 +58,8 @@ module XC2CJTAG(
5758
output reg[ADDR_BITS-1:0] config_write_addr = 0;
5859
output reg[SHREG_WIDTH-1:0] config_write_data = 0;
5960

61+
output wire config_done;
62+
6063
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6164
// The core JTAG state machine
6265

@@ -195,6 +198,8 @@ module XC2CJTAG(
195198
reg configured = 0;
196199
reg read_locked = 0;
197200

201+
assign config_done = configured;
202+
198203
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
199204
// The instruction register
200205

‎hdl/xc2c-model/XC2CMacrocell.v

+17-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,25 @@ module XC2CMacrocell(
3737
output reg mc_out;
3838

3939
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
40-
// XOR logic
40+
// Macrocell XOR
41+
42+
reg xor_out;
43+
44+
always @(*) begin
45+
46+
case(config_bits[9:8])
47+
2'h0: xor_out <= or_term ^ 1'b0;
48+
2'h1: xor_out <= or_term ^ ~pterm_c;
49+
2'h2: xor_out <= or_term ^ pterm_c;
50+
2'h3: xor_out <= or_term ^ 1'b1;
51+
endcase
52+
end
53+
54+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
55+
// Final output muxing
4156

4257
always @(*) begin
43-
mc_out <= config_bits == 27'b000001111001111110011111100;
58+
mc_out <= xor_out;
4459
end
4560

4661
endmodule

0 commit comments

Comments
 (0)
Please sign in to comment.