Skip to content

Instantly share code, notes, and snippets.

@fbrosser
fbrosser / main.c
Created January 28, 2018 08:05
Piezo piano
int IMLength = 70;
String IMNotes[] = {"G4","G4", "G4", "D#4/Eb4", "A#4/Bb4", "G4", "D#4/Eb4","A#4/Bb4", "G4", "D5", "D5", "D5", "D#5/Eb5", "A#4/Bb4", "F#4/Gb4", "D#4/Eb4","A#4/Bb4", "G4", "G5","G4","G4","G5","F#5/Gb5", "F5","E5","D#5/Eb5","E5", "rest", "G4", "rest","C#5/Db5","C5","B4","A#4/Bb4","A4","A#4/Bb4", "rest", "D#4/Eb4", "rest", "F#4/Gb4", "D#4/Eb4","A#4/Bb4", "G4" ,"D#4/Eb4","A#4/Bb4", "G4"};
int IMBeats[] = {8, 8, 8, 6, 2, 8, 6, 2, 16, 8, 8, 8, 6, 2, 8, 6, 2, 16, 8, 6, 2, 8, 6, 2, 2, 2, 2, 6, 2, 2, 8, 6, 2, 2, 2, 2, 6, 2, 2, 9, 6, 2, 8, 6, 2, 16};
int IMTempo = 50;
int RTLength = 19;
String RTNotes[] = {"F4", "F4", "F4", "A#4/Bb4", "F5", "D#5/Eb5", "D5", "C5", "A#5/Bb5", "F5", "D#5/Eb5", "D5", "C5", "A#5/Bb5", "F5", "D#5/Eb5", "D5", "D#5/Eb5", "C5"};
int RTBeats[] = {21, 21, 21, 128, 128, 21, 21, 21, 128, 64, 21, 21, 21, 128, 64, 21, 21, 21, 128};
int RTTempo = 50;
void game_functions::move_ghosts()
{
for(int i=0;i<num_of_ghosts;i++)
{
if(stuck>(30*i)+10)
{
if(ghosts[i].get_scared()==0) // Om spöket är vid sina sinnes fulla bruk
{
int pq = rand()%10+1;
@fbrosser
fbrosser / Output4.v
Created November 20, 2012 06:33
Output4.v
10111101100000111010010110101011
10111100110100110100100110100111
00111110111111011111000101101010
10111101010010111100101110100110
00111110110011100000011010011000
10111101101101000010000100011000
00111000011110001100100100001111
10111110010100001011001010100100
10111101100101111010011101010110
10111111001111111001101011001101
@fbrosser
fbrosser / gist:4116403
Created November 20, 2012 06:32
Output3.v
10111110100010111011001111111011
00111111001110100101110010010100
10111111000110101001110010101110
00111110110101110010100010000011
00111110000011100001101001100111
00111111010111011111001001100101
10111111010000100101101000000111
10111110111101110100011011011011
10111111010110110111010000111100
10111111101100101111001001010100
@fbrosser
fbrosser / Stimulus4.v
Created November 20, 2012 06:31
Stimulus4.v
// TEST #1
// -0.34702802744 - 0.185232380239 = -0.0642808275323
// Expected Z = 10111101100000111010010110101011
#10 a = 32'b10111110101100011010110110101000; b = 32'b00111110001111011010110110001111; operation = 1'b1; $display("%b", result);
// TEST #2
// -0.631432573103 + -0.0408467302274 = 0.0257919559703
// Expected Z = 10111100110100110100100110100111
#10 a = 32'b10111111001000011010010110010001; b = 32'b10111101001001110100111011100111; operation = 1'b0; $display("%b", result);
@fbrosser
fbrosser / Stimulus3.v
Created November 20, 2012 06:30
Stimulus3.v
// TEST #1
// 0.429198640144 + -0.702056150138 = -0.272857509994
// Expected Z = 10111110100010111011001111111011
#10 a = 32'b00111110110110111011111111101101; b = 32'b10111111001100111011100111110100; operation = 1'b0; $display("%b", result);
// TEST #2
// 0.86240205042 + -0.134426927979 = 0.727975122441
// Expected Z = 00111111001110100101110010010100
#10 a = 32'b00111111010111001100011001100001; b = 32'b10111110000010011010011100110110; operation = 1'b0; $display("%b", result);
@fbrosser
fbrosser / Stimulus3.v
Created November 20, 2012 06:30
Stimulus3.v
// TEST #1
// 0.429198640144 + -0.702056150138 = -0.272857509994
// Expected Z = 10111110100010111011001111111011
#10 a = 32'b00111110110110111011111111101101; b = 32'b10111111001100111011100111110100; operation = 1'b0; $display("%b", result);
// TEST #2
// 0.86240205042 + -0.134426927979 = 0.727975122441
// Expected Z = 00111111001110100101110010010100
#10 a = 32'b00111111010111001100011001100001; b = 32'b10111110000010011010011100110110; operation = 1'b0; $display("%b", result);
@fbrosser
fbrosser / gist:4108856
Created November 19, 2012 03:57
Testbench FP Results
10111111100000110001000001000001
01000001110110010101101010011111
01000010100101110100101100100111
11000000101011011000110110011000
01000000010101100011010000011010
11000000110000001011110101000000
01000001101001100110001001111111
01000010000000000100101111100100
01000000011011100100100100111001
01000000000000111101111101010100
@fbrosser
fbrosser / gist:4108854
Created November 19, 2012 03:56
Testbench FP
// TEST #1
// -6.55504723008 + 0.156205364091 = -1.02393353921
// Expected Z = 10111111100000110001000001000001
#10 a = 32'b11000000110100011100001011110010; b = 32'b00111110000111111111010001001101; operation = 1'b0; $display("%b", result);
// TEST #2
// 3.0960619702 + 8.77542136981 = 27.1692483755
// Expected Z = 01000001110110010101101010011111
#10 a = 32'b01000000010001100010010111100001; b = 32'b01000001000011000110100000100000; operation = 1'b0; $display("%b", result);
@fbrosser
fbrosser / gist:4057008
Created November 12, 2012 01:05
35x18 Multiplier
DSP48E1 #(
// Feature Control Attributes: Data Path Selection
.A_INPUT("DIRECT"), // Selects A input source, "DIRECT" (A port) or "CASCADE" (ACIN port)
.B_INPUT("DIRECT"), // Selects B input source, "DIRECT" (B port) or "CASCADE" (BCIN port)
.USE_DPORT("FALSE"), // Select D port usage (TRUE or FALSE)
.USE_MULT("MULTIPLY"), // Select multiplier usage ("MULTIPLY", "DYNAMIC", or "NONE")
// Pattern Detector Attributes: Pattern Detection Configuration
.AUTORESET_PATDET("NO_RESET"), // "NO_RESET", "RESET_MATCH", "RESET_NOT_MATCH"
//.MASK(48'h3fffffffffff), // 48-bit mask value for pattern detect (1=ignore)