-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShooting.tlv
More file actions
119 lines (100 loc) · 5.17 KB
/
Shooting.tlv
File metadata and controls
119 lines (100 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
\m5_TLV_version 1d: tl-x.org
\m5
/ A development template for:
/
/ /----------------------------------------------------------------------------\
/ | The First Annual Makerchip ASIC Design Showdown, Summer 2025, Space Battle |
/ \----------------------------------------------------------------------------/
/
/ Each player or team modifies this template to provide their own custom spacecraft
/ control circuitry. This template is for teams using TL-Verilog. A Verilog-based
/ template is provided separately. Monitor the Showdown Slack channel for updates.
/ Use the latest template for submission.
/
/ Just 3 steps:
/ - Replace all YOUR_GITHUB_ID and YOUR_TEAM_NAME.
/ - Code your logic in the module below.
/ - Submit by Sun. July 26, 11 PM IST/1:30 PM EDT.
/
/ Showdown details: https://www.redwoodeda.com/showdown-info and in the reposotory README.
/
/
/ Your circuit should drive the following signals for each of your ships, in /ship[2:0]:
/ /ships[2:0]
/ $xx_acc[3:0], $yy_acc[3:0]: Attempted acceleration for each of your ships (if sufficient energy);
/ capped by max_acceleration (see showdown_lib.tlv). (use "\$signed($yy_acc) for signed math)
/ $attempt_fire: Attempt to fire (if sufficient energy remains).
/ $fire_dir[1:0]: Direction to fire (if firing). (For the first player: 0 = right, 1 = down, 2 = left, 3 = up).
/ $attempt_cloak: Attempted actions for each of your ships (if sufficient energy remains).
/ $attempt_shield: Attempt to use shields (if sufficient energy remains).
/ Based on the following inputs, previous state from the enemy in /prev_enemy_ship[2:0]:
/ /ship[2:0]
/ *clk: Clock; used implicitly by TL-Verilog constructs, but you can use this in embedded Verilog.
/ $reset: Reset.
/ $xx_p[7:0], $yy_p[7:0]: Position of your ships as affected by previous cycle's acceleration. (signed value, unsigned type)
/ $energy[7:0]: The energy supply of each ship, as updated by inputs last cycle.
/ $destroyed: Asserted if and when the ships are destroyed.
/ /enemy_ship[2:0]: Reflecting enemy input in the previous cycle.
/ $xx_p[7:0], $yy_p[7:0]: Positions of enemy ships. (signed value, unsigned type)
/ $cloaked: Whether the enemy ships are cloaked; if asserted enemy xx_p and xy_p did not update.
/ $destroyed: Whether the enemy ship has been destroyed.
/ See also the game parameters in the header of `showdown_lib.tlv`.
use(m5-1.0)
var(viz_mode, devel) /// Enables VIZ for development.
/// Use "devel" or "demo". ("demo" will be used in competition.)
// Modify this TL-Verilog macro to implement your control circuitry.
// Replace YOUR_GITHUB_ID with your GitHub ID, excluding non-word characters (alphabetic, numeric,
// and "_" only)
\TLV team_YOUR_GITHUB_ID(/_top)
/ship[*]
//Decide to shoot if offset & direction favorable
// Figure out timing for shooting ($should_shoot)
// Shoot if energy and if ship is in radius and if ship moving towards us
// Reserve 4 energy/clk for movement
// INPUTS / REMOVE ME
$enemy_radius = 0;
$dir_good = 1;
$ready = 1;
$fire_dir[1:0] = 0; // right
$should_shoot = $ready && $enemy_radius < 32 && $dir_good;
$attempt_fire = $should_shoot && $energy > 25 + 4;
// [Optional]
// Visualization of your logic for each ship.
\TLV team_YOUR_GITHUB_ID_viz(/_top, _team_num)
m5+io_viz(/_top, _team_num) /// Visualization of your IOs.
\viz_js
m5_DefaultTeamVizBoxAndWhere()
// Add your own visualization of your own logic here, if you like, within the bounds {left: 0..100, top: 0..100}.
render() {
// ... draw using fabric.js and signal values. (See VIZ docs under "LEARN" menu.)
return [
// For example...
new fabric.Text('$destroyed'.asBool() ? "I''m dead! ☹️" : "I''m alive! 😊", {
left: 10, top: 50, originY: "center", fill: "black", fontSize: 10,
})
];
},
// Compete!
// This defines the competition to simulate (for development).
// When this file is included as a library (for competition), this code is ignored.
\SV
// Include the showdown framework.
m4_include_lib(https://raw.githubusercontent.com/rweda/showdown-2025-space-battle/a211a27da91c5dda590feac280f067096c96e721/showdown_lib.tlv)
m5_makerchip_module
\TLV
// Enlist teams for battle.
// Your team as the first. Provide:
// - your GitHub ID, (as in your \TLV team_* macro, above)
// - your team name--anything you like (that isn't crude or disrespectful)
m5_team(YOUR_GITHUB_ID, YOUR_TEAM_NAME)
// Choose your opponent.
// Note that inactive teams must be commented with "///", not "//", to prevent M5 macro evaluation.
///m5_team(random, Random)
///m5_team(sitting_duck, Sitting Duck)
m5_team(demo2, Test 1)
// Instantiate the Showdown environment.
m5+showdown(/top, /secret)
*passed = /secret$passed || *cyc_cnt > 100; // Defines max cycles, up to ~600.
*failed = /secret$failed;
\SV
endmodule