随笔分类 - 找工作-手撕代码系列
摘要:1、原题 2、代码 open IN, '<', 'File1.txt' or die 'The file does not exist!'; open OUT, '>', 'File2.txt' or die 'The file does not exist!'; while(<IN>) { cho
阅读全文
摘要:1、原题 2、代码 class packet; bit [3:0] address; rand bit [2:0] command; rand bit [7:0] payload; rand bit parity; function new(bit [3:0] a); //构造函数里的形式变量不要与
阅读全文
摘要:1、原题 2、代码 `timescale 1ns / 1ps module my_transmitter( input clk, //Clock input rst_n, //Asynchronous reset(active low) input [1:0] gap, //the stop int
阅读全文
摘要:1、代码 `timescale 1ns / 1ps module pulse_synchronizer( input clk1, input clk2, input rstn, input pulse_in, output pulse_out ); reg reg1_clk1; always @(p
阅读全文
摘要:1、原题 2、代码 @A = (5,6,7); # 数组用@和圆括号,用$A[index]访问;哈希用%和圆括号,用 # $A{'key'}访问 @B = (6,7,8); @intersection; @union; # 计算交集,依次取出A中元素,判断其是否与B中的某个元素相等 foreach
阅读全文
摘要:1、原题 2、代码 module sequence_detect( input clk, input rst_n, input [7:0] stringB_in, input stringB_en , input stringB_over , output reg [4:0] location, o
阅读全文
摘要:1、原题 2、代码 class class_a; rand bit signed [7:0] a[4]; bit [1:0] mode; function new(bit [1:0] mode); // 注意分号结尾 mode = mode; endfunction constraint reaso
阅读全文
摘要:1、原题 2、perl脚本 print " Method 1 \n"; open IN,'<','anna-karenina.txt'; while(<IN>){ chomp; $line = $_; $line =~ s/[ \. , ? ! ; : ' " ( ) { } \[ \]]/ /g;
阅读全文
摘要:1、原题 class class_a; virtual function void print_name(); $display("this is class_a"); endfunction endclass class class_b extends class_a; virtual funct
阅读全文
摘要:1、perl脚本 open IN, "<", "data.txt" or die "The file does not exist!"; $line = 0; # 文本总的行数 while(<IN>){ chomp; #print("$_\n"); push(@line_array,$_); # 将
阅读全文
摘要:参考博客:https://blog.csdn.net/hengzo/article/details/49683707 1、基本框图 1)双端口RAM加两个读写指针 2)写数据、写使能、写满;读数据、读使能、读满 2、代码思路 1)Full和Empty的产生:使用fifo_counter记录FIFO
阅读全文
摘要:参考博客:https://www.cnblogs.com/guolongnv/articles/6906929.html 1、基本概念 1)?表示z,而不是“dont care” 2)区分: case语句的表达式的值有4中情况:0、1、z、x。4种是不同的,故表达式要严格的相等才可以操作分支语句。
阅读全文
摘要:参考博文:https://blog.csdn.net/alangaixiaoxiao/article/details/81432144 带将空和将满信号的:https://www.cnblogs.com/lyc-seu/p/12439203.html 1、概述 异步FIFO设计的关键是产生“写满”和
阅读全文
摘要:1、概述 格雷码执行加1操作最多只会变1位,可用在多位地址指针中消除毛刺。 2、verilog代码 1 `timescale 1ns / 1ps 2 3 module gray_adder 4 #(parameter length = 5) 5 ( 6 input clk, 7 input rstn
阅读全文
摘要:一、占空比50%的奇数分频 1、实现思路 实现奇数(N)分频,分别用上升沿计数到(N-1)/2,再计数到N-1;用下降沿计数到(N-1)/2,再计数到N-1,得到两个波形,然后把它们相或即可得到N分频。 2、代码 1 module fp_odd(clk_in,rst_n,cnt_p,cnt_n,cl
阅读全文