- 博客(24)
- 资源 (1)
- 收藏
- 关注
原创 Alpha-beta 剪枝算法求解一字棋问题
#include<iostream>#define HUMAN 1#define COMPUTER 0#define N 3using namespace std;char A[N][N] = {'_','_','_','_','_','_','_','_','_'};int Iswin(){ for(int i=0;i<3;i++){ if(A[i][0]=='X'&&A[i][1]=='X'&&A[i][2]=='X'){
2021-05-24 16:13:48
1176
原创 脉冲宽度调制(PWM)
`timescale 1ns / 1ps// PERIOD表示PWM占几个输入时钟周期;HTIME表示高电平占几个输入时钟周期;N表示计数器的位宽module pwm #(parameter PERIOD = 10, HTIME = 3, N = 4) ( input sys_clk, input sys_rst_n, output logic o_pwm ); logic [N - 1 : 0] r_cnt;
2021-05-13 11:39:53
1141
原创 使能时钟
`timescale 1ns / 1psmodule clken #(parameter SYS_CLK_FREQ = 100_000_000, TARGET_CLK_FREQ = 10_000_000, N = 4) ( input sys_clk, input sys_rst_n, output logic clk_flag ); localparam CNT_MAX = SYS_CLK_FREQ / .
2021-05-13 11:38:47
677
1
原创 时钟分频
`timescale 1ns / 1ps// SYS_CLK_FREQ表示输入时钟频率;TARGET_CLK_FREQ表示目标时钟频率;N表示计数器的位宽module clkdiv #(parameter SYS_CLK_FREQ = 100_000_000, TARGET_CLK_FREQ = 10_000_000, N = 3) ( input sys_clk, input sys_rst_n, output logic clk_out
2021-05-13 11:37:41
708
原创 按键去抖动
`timescale 1ns / 1psmodule debouncing ( input sys_clk, input sys_rst_n, input clk_flag, input i_btn, output logic o_btn ); reg delay0; reg delay1; reg delay2; reg delay3;
2021-05-13 11:36:07
260
原创 边沿检测
`timescale 1ns / 1psmodule edge_det ( input sys_clk, input sys_rst_n, input i_btn, output logic posedge_flag, output logic negedge_flag ) reg data_in_d1; reg data_in_d2; reg data_
2021-05-13 11:34:53
314
原创 4位逻辑计算单元alu的实现
1:使用4个全加器结构化建模形成一个行波进位加法器2:使用一个行波进位加法器实现有符号数和无符号数的加减法3:实现功能如下fulladder.sv(全加器)`timescale 1ns / 1psmodule fulladder( input logic A, input logic B, input logic Cin, output logic Cout, output logic S ); always_comb begin
2021-04-28 22:50:46
8001
8
原创 MPI矩阵转置—棋盘划分
#include <iostream>#include <cmath>#include <mpi.h> const int n=12000;int a[n][n];int b[n][n];using namespace std;MPI_Status status;int main(int argc, char *argv[]){ int my_rank,group_size; MPI_Init(&argc, &argv);
2021-04-27 16:32:33
977
1
原创 MPI矩阵转置——直角划分
编译指令 mpicxx -g -Wall -o mpi mpi.cpp#include <stdlib.h>#include <iostream>#include<mpi.h>const int n=3000;//可以自己赋值int a[n][n];int b[n][n];using namespace std;MPI_Status status; int main(int argc, char * argv[]) { int my_ra
2021-04-21 20:00:41
694
原创 5输入的多数表决器(结构化建模)
采用 3 个 74LS138 模块、和基本逻辑门电路实现 5 输入多数表决器dec_74LS138(3-8 译码器)`timescale 1ns / 1ps//////////////////////////////////////////////////////////////////////////////////// Company: // Engineer: // // Create Date: 2021/04/08 10:25:45// Design Name: // Mod.
2021-04-12 16:04:36
4375
原创 5输入的多数表决器(行为建模)
行为建模实现5输入的多数表决器voter5`timescale 1ns / 1ps//////////////////////////////////////////////////////////////////////////////////// Company: // Engineer: // // Create Date: 2021/04/07 19:40:02// Design Name: // Module Name: voter5// Project Name: //.
2021-04-08 22:01:08
1667
1
原创 七段数码管显示译码器
`timescale 1ns/1psmodule hex7seg( input [3 : 0] x, output logic [6 : 0] a_to_g ); always_comb begin case(x) 4'b0000: a_to_g = 70000001; 4'b0001: a_to_g = 7'b1001111; 4'b0010: a_to_g = 7'b0010010; 4'b0011: a_to_g = 7'b00001
2021-04-05 11:22:56
3678
原创 3-8译码器(基于for循环语句)
`timescale 1ns/1psmodule dec3to8 ( input [2 : 0] Din, input en, output logic [7 : 0] Y ); always_comb begin if(en==1) begin int i; for(i=0;i<8;i=i+1) begin if(Din[0]*1+Din[1]*2+Din[2]*4==i) begin Y[i]=1;
2021-04-05 11:21:24
1390
原创 3-8译码器(基于分支语句
`timescale 1ns/1psmodule dec3to8 ( input [2 : 0] Din, input en, output logic [7 : 0] Y ); always_comb begin case({en,Din}) 4'b0000: Y=8'b00000000; 4'b1000: Y=8'b00000001; 4'b1001: Y=8'b00000010; 4'b1010: Y=8'b00000100
2021-04-05 11:20:10
706
原创 4位八选一多路选择器
`timescale 1ns/1psmodule mux8_4bits( input [3 : 0] D0, input [3 : 0] D1, input [3 : 0] D2, input [3 : 0] D3, input [3 : 0] D4, input [3 : 0] D5, input [3 : 0] D6, input [3 : 0] D7, input [2 : 0] sel, output log
2021-04-03 16:50:34
2041
原创 八选一多路选择器(结构化建模)
`timescale 1ns/1psmodule mux2( input [1 : 0] D, input sel, output Y ); assign Y = (sel == 0)? D[0] : D[1];endmodule`timescale 1ns/1psmodule mux4( input [3 : 0] D, input [1 : 0] sel, output Y );
2021-04-03 16:45:49
2599
原创 八选一多路选择器(case语句)
`timescale 1ns/1psmodule mux8( input [7 : 0] D, input [2 : 0] sel, output logic Y ); always_comb begin case(sel[0]*1+sel[1]*2+sel[2]*4) 7:Y=D[7]; 6:Y=D[6]; 5:Y=D[5]; 4:Y=D[4]; 3:Y=D[3]; 2:Y=D[2]; 1:
2021-04-03 16:41:02
3666
原创 八选一多路选择器(if...else语句)
`timescale 1ns/1psmodule mux8( input [7 : 0] D, input [2 : 0] sel, output logic Y ); always_comb begin if(sel[0]*1+sel[1]*2+sel[2]*4==7) Y=D[7]; else if(sel[0]*1+sel[1]*2+sel[2]*4==6) Y=D[6]; else if(sel[0]*1+sel[1]*2+sel[2]*
2021-04-03 16:40:06
3081
2
原创 八选一多路选择器(持续赋值语句)
`timescale 1ns/1psmodule mux8( input [7 : 0] D, input [2 : 0] sel, output Y ); assign Y=D[sel[0]*1+sel[1]*2+sel[2]*4];endmodule
2021-04-03 16:38:52
1587
原创 4位格雷码转换器
`timescale 1ns/1psmodule gray_4bits ( input [3 : 0] Din, input EN, input gray_n, output logic [3 : 0] Dout, output logic valid ); always_comb begin if(gray_n==0)begin if(EN==1) begin case(Din) 4'b0001: beg
2021-04-03 16:35:53
1139
原创 4位二进制-BCD码转换器
`timescale 1ns/1psmodule bin2bcd_4bits ( input [3 : 0] bin, input EN, output logic [4 : 0] bcd, output logic valid ); always_comb begin if(EN==1) begin case(bin) 4'b0001: begin bcd = 5'b00001 ; valid=1; end 4'
2021-04-03 16:34:39
5187
原创 二进制优先编码器
`timescale 1ns/1psmodule prio_enc8to3 ( input [7 : 0] Din, input EN, output logic [2 : 0] Y, output logic valid ); always_comb begin if(EN==1) begin if(Din[7]==1) begin Y = 3'b111 ; valid=1; end else if(Din[6]==1) be
2021-04-03 16:33:24
1032
原创 二进制普通编码器
`timescale 1ns/1psmodule enc8to3 ( input [7 : 0] Din, input EN, output logic [2 : 0] Y, output logic valid ); always_comb begin if(EN==1) begin case(Din) 8'b0000_0001:begin Y = 3'b000 ; valid=1; end 8'b0000
2021-04-03 16:29:02
1664
原创 矩阵乘法链求解(迭代)
矩阵乘法链求解(迭代)/* 本算法使用迭代方法来求解最优乘法数: 按 s = 2,3,…,q-1 的顺序计算c (i, i+s),每个c 和kay 仅需计算一次。 该函数的复杂性为 Θ(q^3)。*/#include<iostream>using namespace std;const int size=1000;int c[size][size];int kay[size][size];void MatrixChain(int r[], int q,int c[size
2020-12-18 20:18:47
571
1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人