|
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 09:02:41 09/15/2011
// Design Name:
// Module Name: triwave
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module triwave(clk,wave);
input clk;
output [31:0] wave;
reg [31:0] wave;
reg rfd;
wire [17:0] dividend;
wire [7:0] divisor;
wire [17:0] quotient;
wire [13:0] fractional;
wire [14:0] a;
wire [14:0] b;
wire [14:0] s;
reg [14:0] counter;
always @(posedge clk) begin
if((counter>=0)&&(counter<10000)) begin
counter<=counter+1;
end
else if(counter==10000) begin
counter<=0;
end
end
divip wavediv (
.clk(clk),
.rfd(rfd),
.dividend(dividend), // Bus [17 : 0]
.divisor(divisor), // Bus [7 : 0]
.quotient(quotient), // Bus [17 : 0]
.fractional(fractional)); // Bus [13 : 0]
subip wavesub (
.a(a), // Bus [14 : 0]
.b(b), // Bus [14 : 0]
.clk(clk),
.s(s)); // Bus [14 : 0]
always begin
if((counter>=0)&&(counter<5000)) begin
dividend<=counter;
divisor<=50;
end
else if((counter>=5000)&&(counter<10000))
a<=10000;
b<=counter;
dividend<=s;
divisor<=50;
end
end
assign wave=quotient<<14+fractional;
endmodule |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|