Skip to content

Commit 546ceb6

Browse files
committedJun 25, 2017
XC2CModel: Continued initial macrocell implementation
1 parent 0fc9a9c commit 546ceb6

File tree

3 files changed

+63
-21
lines changed

3 files changed

+63
-21
lines changed
 

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

+20-17
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ module XC2CDevice(
174174
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
175175
// The JTAG TAP (for now, basic bitstream config only)
176176

177+
wire config_done_rst;
178+
177179
XC2CJTAG #(
178180
.MACROCELLS(MACROCELLS),
179181
.PACKAGE(PACKAGE),
@@ -195,14 +197,15 @@ module XC2CDevice(
195197
.config_write_addr(config_write_addr),
196198
.config_write_data(config_write_data),
197199

198-
.config_done(done)
200+
.config_done(done),
201+
.config_done_rst(config_done_rst)
199202
);
200203

201204
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
202205
// Global routing
203206

204-
//TODO: input buffers and muxes for these based on InZ etc
205-
wire[31:0] macrocell_to_zia = 32'h0;
207+
//TODO: muxes for iob_in
208+
wire[31:0] macrocell_to_zia;
206209
wire[31:0] ibuf_to_zia = iob_in;
207210

208211
//Left side (FB2)
@@ -272,8 +275,8 @@ module XC2CDevice(
272275
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
273276
// Macrocells
274277

275-
wire[15:0] left_mc_out;
276-
wire[15:0] right_mc_out;
278+
wire[15:0] left_mc_to_obuf;
279+
wire[15:0] right_mc_to_obuf;
277280

278281
genvar g;
279282
generate
@@ -285,7 +288,9 @@ module XC2CDevice(
285288
.pterm_b(left_pterms[g*3 + 9]),
286289
.pterm_c(left_pterms[g*3 + 10]),
287290
.or_term(left_orterms[g]),
288-
.mc_out(left_mc_out[g])
291+
.config_done_rst(config_done_rst),
292+
.mc_to_zia(macrocell_to_zia[g + 16]),
293+
.mc_to_obuf(left_mc_to_obuf[g])
289294
);
290295

291296
XC2CMacrocell right(
@@ -294,7 +299,9 @@ module XC2CDevice(
294299
.pterm_b(right_pterms[g*3 + 9]),
295300
.pterm_c(right_pterms[g*3 + 10]),
296301
.or_term(right_orterms[g]),
297-
.mc_out(right_mc_out[g])
302+
.config_done_rst(config_done_rst),
303+
.mc_to_zia(macrocell_to_zia[g]),
304+
.mc_to_obuf(right_mc_to_obuf[g])
298305
);
299306

300307
end
@@ -311,18 +318,14 @@ module XC2CDevice(
311318
//Drive all unused outputs to 0, then hook up our outputs
312319
//Should be X, !X, X, X
313320
assign iob_out[31:7] = 25'h0;
314-
assign iob_out[6] = right_mc_out[6];
315-
assign iob_out[5] = right_mc_out[5];
316-
assign iob_out[4] = right_mc_out[4];
317-
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
321+
assign iob_out[6] = right_mc_to_obuf[6];
322+
assign iob_out[5] = right_mc_to_obuf[5];
323+
assign iob_out[4] = right_mc_to_obuf[4];
324+
assign iob_out[3] = right_mc_to_obuf[3];
325+
323326
assign iob_out[2:0] = 3'h0;
324327

325328
//Helper to keep stuff from getting optimized out
326-
assign dbgout = ^right_mc_out ^ ^left_mc_out;
329+
assign dbgout = ^macrocell_to_zia ^ ^right_mc_to_obuf ^ ^left_mc_to_obuf;
327330

328331
endmodule

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module XC2CJTAG(
2525
config_erase,
2626
config_read_en, config_read_addr, config_read_data,
2727
config_write_en, config_write_addr, config_write_data,
28-
config_done);
28+
config_done, config_done_rst);
2929

3030
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3131
// Device configuration
@@ -59,6 +59,7 @@ module XC2CJTAG(
5959
output reg[SHREG_WIDTH-1:0] config_write_data = 0;
6060

6161
output wire config_done;
62+
output reg config_done_rst = 0;
6263

6364
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6465
// The core JTAG state machine
@@ -242,6 +243,7 @@ module XC2CJTAG(
242243
always @(posedge tck) begin
243244

244245
config_erase <= 0;
246+
config_done_rst <= 0;
245247

246248
case(state)
247249

@@ -286,6 +288,7 @@ module XC2CJTAG(
286288
//TODO: check DONE / transfer bits first
287289
if(ir_shreg == INST_ISC_PROGRAM) begin
288290
configured <= 1;
291+
config_done_rst <= 1;
289292
end
290293

291294
//TODO: copy EEPROM to RAM when we get an ISC_INIT command

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

+39-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ module XC2CMacrocell(
2020
config_bits,
2121
pterm_a, pterm_b, pterm_c,
2222
or_term,
23-
mc_out
23+
mc_to_zia, mc_to_obuf,
24+
config_done_rst
2425
);
2526

2627
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -33,8 +34,10 @@ module XC2CMacrocell(
3334
input wire pterm_c;
3435

3536
input wire or_term;
37+
input wire config_done_rst;
3638

37-
output reg mc_out;
39+
output reg mc_to_zia;
40+
output reg mc_to_obuf;
3841

3942
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4043
// Macrocell XOR
@@ -51,11 +54,44 @@ module XC2CMacrocell(
5154
endcase
5255
end
5356

57+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
58+
// Macrocell flipflop
59+
60+
reg mc_dff = 1;
61+
62+
//Flipflop reset
63+
always @(/*posedge config_done_rst*/*) begin
64+
mc_dff <= !config_bits[0];
65+
end
66+
5467
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5568
// Final output muxing
5669

70+
//TODO: mux for bit 15 (ibuf/mc flipflop)
71+
5772
always @(*) begin
58-
mc_out <= xor_out;
73+
74+
//Enable for macrocell->ZIA driver (active low so we're powered down when device is blank)
75+
if(!config_bits[12]) begin
76+
77+
//See where macrocell->ZIA driver should go
78+
if(config_bits[13])
79+
mc_to_zia <= mc_dff;
80+
else
81+
mc_to_zia <= xor_out;
82+
83+
end
84+
85+
//Output driver powered down, feed a constant zero into the ZIA to prevent spurious toggles
86+
else
87+
mc_to_zia <= 1'b0;
88+
89+
//Mux for pad driver
90+
if(config_bits[7])
91+
mc_to_obuf <= xor_out;
92+
else
93+
mc_to_obuf <= mc_dff;
94+
5995
end
6096

6197
endmodule

0 commit comments

Comments
 (0)
Please sign in to comment.