1 Star 0 Fork 0

ic-starter/up5k

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
serial.v 1.91 KB
一键复制 编辑 原始数据 按行查看 历史
/** \file
* Test the serial output to the FTDI cable.
*
* The schematic disagrees with the PCF, but the PCF works...
*
* The SPI flash chip select *MUST* be pulled high to disable the
* flash chip, otherwise they will both be driving the bus.
*
* This may interfere with programming; `iceprog -e 128` should erase enough
* to make it compliant for re-programming
*
* The USB port will have to be cycled to get the FTDI to renumerate as
* /dev/ttyUSB0. Not sure what is going on with iceprog.
*/
`include "util.v"
`include "uart.v"
module top(
output led_r,
output led_g,
output led_b,
output serial_txd,
input serial_rxd,
output spi_cs,
output gpio_2
);
assign spi_cs = 1; // it is necessary to turn off the SPI flash chip
wire debug0 = gpio_2;
wire clk_48;
wire reset = 0;
SB_HFOSC u_hfosc (
.CLKHFPU(1'b1),
.CLKHFEN(1'b1),
.CLKHF(clk_48)
);
reg [31:0] counter;
always @(posedge clk_48)
if (reset)
counter <= 0;
else
counter <= counter + 1;
assign led_g = 1;
assign led_b = serial_rxd; // idles high
// generate a 1 MHz serial clock from the 48 MHz clock
wire clk_1;
divide_by_n #(.N(48)) div(clk_48, reset, clk_1);
reg [7:0] uart_txd;
reg uart_txd_strobe;
wire uart_txd_ready;
uart_tx txd(
.mclk(clk_48),
.reset(reset),
.baud_x1(clk_1),
.serial(serial_txd),
.ready(uart_txd_ready),
.data(uart_txd),
.data_strobe(uart_txd_strobe)
);
assign debug0 = serial_txd;
reg [3:0] byte_counter;
always @(posedge clk_48) begin
led_r <= 1;
uart_txd_strobe <= 0;
if (reset) begin
// nothing
byte_counter <= 0;
end else
if (uart_txd_ready && !uart_txd_strobe && counter[14:0] == 0) begin
// ready to send a new byte
uart_txd_strobe <= 1;
if (byte_counter == 0)
uart_txd <= "\r";
else
if (byte_counter == 1)
uart_txd <= "\n";
else
uart_txd <= "A" + byte_counter - 2;
byte_counter <= byte_counter + 1;
led_r <= 0;
end
end
endmodule
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ic-starter/up5k.git
git@gitee.com:ic-starter/up5k.git
ic-starter
up5k
up5k
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385