Skip to content

Instantly share code, notes, and snippets.

@turqq

turqq/1q.md Secret

Last active November 1, 2019 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turqq/301b02a1f16252479e7ba0b2a4bbdae2 to your computer and use it in GitHub Desktop.
Save turqq/301b02a1f16252479e7ba0b2a4bbdae2 to your computer and use it in GitHub Desktop.

I bought a Go board awhile back and only recently have been going through the associated tutorials. I was able to upload the verilog code for this project to my board using iceprog:

https://www.nandland.com/goboard/uart-go-board-project-part1.html

I was able to use screen to send commands to the fpga, but when I compiled the second verilog program (https://www.nandland.com/goboard/uart-go-board-project-part2.html) which sends data back from the fpga to my terminal, nothing worked :) So I went back to the previous project and uploaded it with iceprog, and now I'm not getting any output when I connect via screen.

What are some tips to start debugging what is going on? It seems like a lot of moving pieces.

Commands used for getting the code onto the board:

yosys -p "read_verilog uart_rx_to_7_seg_top.v; read_verilog binary_to_7_segment.v; read_verilog uart_rx.v; synth_ice40 -blif uart_rx_to_7_seg_top.blif" && \
arachne-pnr -d 1k -p ../Go_Board_Constraints.pcf -P vq100 -o uart_rx_to_7_seg_top.asc uart_rx_to_7_seg_top.blif && \
icepack uart_rx_to_7_seg_top.asc uart_rx_to_7_seg_top.bin && \
iceprog uart_rx_to_7_seg_top.bin
///////////////////////////////////////////////////////////////////////////////
// This file converts an input binary number into an output which can get sent
// to a 7-Segment LED. 7-Segment LEDs have the ability to display all decimal
// numbers 0-9 as well as hex digits A, B, C, D, E and F. The input to this
// module is a 4-bit binary number. This module will properly drive the
// individual segments of a 7-Segment LED in order to display the digit.
// Hex encoding table can be viewed at:
// http://en.wikipedia.org/wiki/Seven-segment_display
///////////////////////////////////////////////////////////////////////////////
module Binary_To_7Segment
(
input i_Clk,
input [3:0] i_Binary_Num,
output o_Segment_A,
output o_Segment_B,
output o_Segment_C,
output o_Segment_D,
output o_Segment_E,
output o_Segment_F,
output o_Segment_G
);
reg [6:0] r_Hex_Encoding = 7'h00;
// Purpose: Creates a case statement for all possible input binary numbers.
// Drives r_Hex_Encoding appropriately for each input combination.
always @(posedge i_Clk)
begin
case (i_Binary_Num)
4'b0000 : r_Hex_Encoding <= 7'h7E;
4'b0001 : r_Hex_Encoding <= 7'h30;
4'b0010 : r_Hex_Encoding <= 7'h6D;
4'b0011 : r_Hex_Encoding <= 7'h79;
4'b0100 : r_Hex_Encoding <= 7'h33;
4'b0101 : r_Hex_Encoding <= 7'h5B;
4'b0110 : r_Hex_Encoding <= 7'h5F;
4'b0111 : r_Hex_Encoding <= 7'h70;
4'b1000 : r_Hex_Encoding <= 7'h7F;
4'b1001 : r_Hex_Encoding <= 7'h7B;
4'b1010 : r_Hex_Encoding <= 7'h77;
4'b1011 : r_Hex_Encoding <= 7'h1F;
4'b1100 : r_Hex_Encoding <= 7'h4E;
4'b1101 : r_Hex_Encoding <= 7'h3D;
4'b1110 : r_Hex_Encoding <= 7'h4F;
4'b1111 : r_Hex_Encoding <= 7'h47;
endcase
end // always @ (posedge i_Clk)
// r_Hex_Encoding[7] is unused
assign o_Segment_A = r_Hex_Encoding[6];
assign o_Segment_B = r_Hex_Encoding[5];
assign o_Segment_C = r_Hex_Encoding[4];
assign o_Segment_D = r_Hex_Encoding[3];
assign o_Segment_E = r_Hex_Encoding[2];
assign o_Segment_F = r_Hex_Encoding[1];
assign o_Segment_G = r_Hex_Encoding[0];
endmodule // Binary_To_7Segment
module UART_RX_To_7_Seg_Top
(input i_Clk, // Main Clock
input i_UART_RX, // UART RX Data
// Segment1 is upper digit, Segment2 is lower digit
output o_Segment1_A,
output o_Segment1_B,
output o_Segment1_C,
output o_Segment1_D,
output o_Segment1_E,
output o_Segment1_F,
output o_Segment1_G,
//
output o_Segment2_A,
output o_Segment2_B,
output o_Segment2_C,
output o_Segment2_D,
output o_Segment2_E,
output o_Segment2_F,
output o_Segment2_G);
wire w_RX_DV;
wire [7:0] w_RX_Byte;
wire w_Segment1_A, w_Segment2_A;
wire w_Segment1_B, w_Segment2_B;
wire w_Segment1_C, w_Segment2_C;
wire w_Segment1_D, w_Segment2_D;
wire w_Segment1_E, w_Segment2_E;
wire w_Segment1_F, w_Segment2_F;
wire w_Segment1_G, w_Segment2_G;
// 25,000,000 / 115,200 = 217
UART_RX #(.CLKS_PER_BIT(217)) UART_RX_Inst
(.i_Clock(i_Clk),
.i_RX_Serial(i_UART_RX),
.o_RX_DV(w_RX_DV),
.o_RX_Byte(w_RX_Byte));
// Binary to 7-Segment Converter for Upper Digit
Binary_To_7Segment SevenSeg1_Inst
(.i_Clk(i_Clk),
.i_Binary_Num(w_RX_Byte[7:4]),
.o_Segment_A(w_Segment1_A),
.o_Segment_B(w_Segment1_B),
.o_Segment_C(w_Segment1_C),
.o_Segment_D(w_Segment1_D),
.o_Segment_E(w_Segment1_E),
.o_Segment_F(w_Segment1_F),
.o_Segment_G(w_Segment1_G));
assign o_Segment1_A = ~w_Segment1_A;
assign o_Segment1_B = ~w_Segment1_B;
assign o_Segment1_C = ~w_Segment1_C;
assign o_Segment1_D = ~w_Segment1_D;
assign o_Segment1_E = ~w_Segment1_E;
assign o_Segment1_F = ~w_Segment1_F;
assign o_Segment1_G = ~w_Segment1_G;
// Binary to 7-Segment Converter for Lower Digit
Binary_To_7Segment SevenSeg2_Inst
(.i_Clk(i_Clk),
.i_Binary_Num(w_RX_Byte[3:0]),
.o_Segment_A(w_Segment2_A),
.o_Segment_B(w_Segment2_B),
.o_Segment_C(w_Segment2_C),
.o_Segment_D(w_Segment2_D),
.o_Segment_E(w_Segment2_E),
.o_Segment_F(w_Segment2_F),
.o_Segment_G(w_Segment2_G));
assign o_Segment2_A = ~w_Segment2_A;
assign o_Segment2_B = ~w_Segment2_B;
assign o_Segment2_C = ~w_Segment2_C;
assign o_Segment2_D = ~w_Segment2_D;
assign o_Segment2_E = ~w_Segment2_E;
assign o_Segment2_F = ~w_Segment2_F;
assign o_Segment2_G = ~w_Segment2_G;
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment