1 Star 0 Fork 0

ic-starter/up5k

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
serial-echo.v 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
/** \file
* Test the serial input/output to the FTDI chip.
*
* This configures the serial port at 3 Mb/s and directly routes
* the incoming data to the outbound serial port.
*
* 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.
*/
`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)
);
// pulse the green LED to know that we're alive
reg [31:0] counter;
always @(posedge clk_48)
counter <= counter + 1;
wire pwm_g;
pwm pwm_g_driver(clk_48, 1, pwm_g);
assign led_g = !(counter[25:23] == 0 && pwm_g);
assign led_b = serial_rxd; // idles high
assign led_r = serial_txd; // idles high
assign debug0 = serial_txd;
// generate a 3 MHz/12 MHz serial clock from the 48 MHz clock
// this is the 3 Mb/s maximum supported by the FTDI chip
wire clk_1, clk_4;
divide_by_n #(.N(16)) div1(clk_48, reset, clk_1);
divide_by_n #(.N( 4)) div4(clk_48, reset, clk_4);
wire [7:0] uart_rxd;
wire uart_rxd_strobe;
uart_tx txd(
.mclk(clk_48),
.reset(reset),
.baud_x1(clk_1),
.serial(serial_txd),
.data(uart_rxd),
.data_strobe(uart_rxd_strobe)
);
uart_rx rxd(
.mclk(clk_48),
.reset(reset),
.baud_x4(clk_4),
.serial(serial_rxd),
.data(uart_rxd),
.data_strobe(uart_rxd_strobe)
);
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