Skip to content

Commit

Permalink
XC2CModel: Continued initial macrocell implementation
Browse files Browse the repository at this point in the history
azonenberg committed Jun 25, 2017
1 parent 0fc9a9c commit 546ceb6
Showing 3 changed files with 63 additions and 21 deletions.
37 changes: 20 additions & 17 deletions hdl/xc2c-model/XC2CDevice.v
Original file line number Diff line number Diff line change
@@ -174,6 +174,8 @@ module XC2CDevice(
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The JTAG TAP (for now, basic bitstream config only)

wire config_done_rst;

XC2CJTAG #(
.MACROCELLS(MACROCELLS),
.PACKAGE(PACKAGE),
@@ -195,14 +197,15 @@ module XC2CDevice(
.config_write_addr(config_write_addr),
.config_write_data(config_write_data),

.config_done(done)
.config_done(done),
.config_done_rst(config_done_rst)
);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Global routing

//TODO: input buffers and muxes for these based on InZ etc
wire[31:0] macrocell_to_zia = 32'h0;
//TODO: muxes for iob_in
wire[31:0] macrocell_to_zia;
wire[31:0] ibuf_to_zia = iob_in;

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

wire[15:0] left_mc_out;
wire[15:0] right_mc_out;
wire[15:0] left_mc_to_obuf;
wire[15:0] right_mc_to_obuf;

genvar g;
generate
@@ -285,7 +288,9 @@ module XC2CDevice(
.pterm_b(left_pterms[g*3 + 9]),
.pterm_c(left_pterms[g*3 + 10]),
.or_term(left_orterms[g]),
.mc_out(left_mc_out[g])
.config_done_rst(config_done_rst),
.mc_to_zia(macrocell_to_zia[g + 16]),
.mc_to_obuf(left_mc_to_obuf[g])
);

XC2CMacrocell right(
@@ -294,7 +299,9 @@ module XC2CDevice(
.pterm_b(right_pterms[g*3 + 9]),
.pterm_c(right_pterms[g*3 + 10]),
.or_term(right_orterms[g]),
.mc_out(right_mc_out[g])
.config_done_rst(config_done_rst),
.mc_to_zia(macrocell_to_zia[g]),
.mc_to_obuf(right_mc_to_obuf[g])
);

end
@@ -311,18 +318,14 @@ module XC2CDevice(
//Drive all unused outputs to 0, then hook up our outputs
//Should be X, !X, X, X
assign iob_out[31:7] = 25'h0;
assign iob_out[6] = right_mc_out[6];
assign iob_out[5] = right_mc_out[5];
assign iob_out[4] = right_mc_out[4];
assign iob_out[3] = right_mc_out[3];

//assign iob_out[5] = right_pterms[22]; //pterm, should be copy of x
//assign iob_out[4] = right_mc_out[3]; //led_0, constant 1: OR arrays 0 xor 1
//assign iob_out[3] = right_mc_out[4]; //led_1, passthrough of pterm C
//for MC4 this is pterm 22
assign iob_out[6] = right_mc_to_obuf[6];
assign iob_out[5] = right_mc_to_obuf[5];
assign iob_out[4] = right_mc_to_obuf[4];
assign iob_out[3] = right_mc_to_obuf[3];

assign iob_out[2:0] = 3'h0;

//Helper to keep stuff from getting optimized out
assign dbgout = ^right_mc_out ^ ^left_mc_out;
assign dbgout = ^macrocell_to_zia ^ ^right_mc_to_obuf ^ ^left_mc_to_obuf;

endmodule
5 changes: 4 additions & 1 deletion hdl/xc2c-model/XC2CJTAG.v
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ module XC2CJTAG(
config_erase,
config_read_en, config_read_addr, config_read_data,
config_write_en, config_write_addr, config_write_data,
config_done);
config_done, config_done_rst);

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

output wire config_done;
output reg config_done_rst = 0;

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

config_erase <= 0;
config_done_rst <= 0;

case(state)

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

//TODO: copy EEPROM to RAM when we get an ISC_INIT command
42 changes: 39 additions & 3 deletions hdl/xc2c-model/XC2CMacrocell.v
Original file line number Diff line number Diff line change
@@ -20,7 +20,8 @@ module XC2CMacrocell(
config_bits,
pterm_a, pterm_b, pterm_c,
or_term,
mc_out
mc_to_zia, mc_to_obuf,
config_done_rst
);

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

input wire or_term;
input wire config_done_rst;

output reg mc_out;
output reg mc_to_zia;
output reg mc_to_obuf;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Macrocell XOR
@@ -51,11 +54,44 @@ module XC2CMacrocell(
endcase
end

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Macrocell flipflop

reg mc_dff = 1;

//Flipflop reset
always @(/*posedge config_done_rst*/*) begin
mc_dff <= !config_bits[0];
end

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Final output muxing

//TODO: mux for bit 15 (ibuf/mc flipflop)

always @(*) begin
mc_out <= xor_out;

//Enable for macrocell->ZIA driver (active low so we're powered down when device is blank)
if(!config_bits[12]) begin

//See where macrocell->ZIA driver should go
if(config_bits[13])
mc_to_zia <= mc_dff;
else
mc_to_zia <= xor_out;

end

//Output driver powered down, feed a constant zero into the ZIA to prevent spurious toggles
else
mc_to_zia <= 1'b0;

//Mux for pad driver
if(config_bits[7])
mc_to_obuf <= xor_out;
else
mc_to_obuf <= mc_dff;

end

endmodule

0 comments on commit 546ceb6

Please sign in to comment.